

#include "POSTest.h"
#include <vector>
#include "User.h"
#include "Administrator.h"
#include "Lecturer.h"
#include "ExamTopic.h"


using namespace std;
CPPUNIT_TEST_SUITE_REGISTRATION (POSTest);

// Test addExamTopic() and addQuestion2ExamTopic() function
void POSTest::testAddAccount()
{
    cout << endl << "***Test 1)testAddAccount***" << endl;
    
    User* sys;
    sys = new Administrator("Admin001",-1);
    //Insert Terster as lecturer
    sys->addAccount("Tester001","tester1","1234",1,sys->getUserID()); 
        
    cout << "***Test 1)testAddAccount tested***" << endl << endl;
}
// Test addExamTopic() and addQuestion2ExamTopic() function
void POSTest::testAddTestTopicAndQuestion()
{
    cout << endl << "***Test 2)testAddTestTopicAndQuestion***" << endl;
    Lecturer tester("Tester001");
    string topic = "AutoTest";
    //Add exam topic
    CPPUNIT_ASSERT_EQUAL(tester.addExamTopic(topic,"Total 5 MCQ, 1 mark for each","Tester001"),true);
    //Add test question
    string sel[] = {"Test a....","Test b....","Test c....","Test d...."};
    vector<string> selections(sel,sel+4);
    ExamTopic examTopic;
    examTopic.setTopic(topic);
    examTopic.addQuestion(TestQuestion("Test1",selections,"a"));
    examTopic.addQuestion(TestQuestion("Test2",selections,"b"));
    examTopic.addQuestion(TestQuestion("Test3",selections,"c"));
    examTopic.addQuestion(TestQuestion("Test4",selections,"d"));
    examTopic.addQuestion(TestQuestion("Test5",selections,"a"));
    tester.setExamTopic(examTopic);
    CPPUNIT_ASSERT_EQUAL(tester.addQuestion2ExamTopic(),true);
        
    cout << "***Test 2)testAddTestTopicAndQuestion tested***" << endl << endl;
}

// Test updateExamTopic() and updateQuestion() function
void POSTest::testUpdateExamTopicAndQuestion()
{
    cout << endl << "***Test 3)testUpdateExamTopicAndQuestion***" << endl;
    Lecturer tester("Tester001");
    string topic_org = "AutoTest";
    string topic = "AutoTest2";
    //Update exam topic (topic)
    string sel[] = {"Test a....","Test b....","Test c....","Test d...."};
    vector<string> selections(sel,sel+4);
    ExamTopic examTopic;
    examTopic.setTopic(topic_org);
    tester.setExamTopic(examTopic);
    tester.updateExamTopic(3,"ExamTopic",topic,"Tester001");
    
    //Update test question (Answer))
    tester.updateQuestion(12, "Answer", "c",topic);
        
    cout << "***Test 3)testUpdateExamTopicAndQuestion tested***" << endl << endl;
}








